#pragma once
#include "inc.h"
class GCamera;
class GRender;
class GWindow;

struct WindowMouseInfo
{
	Vector2f orbit_pos;
	Vector2f orbit_delta;
	Vector2f fv_pos;
	Vector2f fv_delta;
	float wheel_delta;
};

struct WindowEvent
{
	char keys[512];
	char buttons[2];
	WindowMouseInfo mouseInfo;
	GWindow* pCurrentWindow;
};

class GWindow
{
public:
	GWindow(int nWidth, int nHeight);
	void Init();
	void Active(GCamera* pCamera);
	GRenderTarget* GetRenderTarget();
	Matrix4f GenViewPortMatrix();
	HWND GetWndHandle();
	void DispatchMsg();
	void WindowDraw();
	void HandleEvent(GCamera* pCamera);

	static LRESULT ProcessEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
	static Vector2f GetMousePos();

	int m_nWidth;
	int m_nHeight;
	static WindowEvent* ms_pEvent;
private:
	void HandleMouseEvent(GCamera* pCamera);
	void UpdateCameraPos(GCamera* pCamera);
	void TryRegisterWndClass();
	float* m_pZBuffer;
	unsigned int* m_pFrameBuffer;
	HWND m_screenHandle;
	HDC m_screenDc;
	static WNDCLASS* ms_pWndClass;
	static bool ms_bRegistedWndClass;
};